package com.wxn.learncompose.pagers

import android.widget.ImageView
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.github.penfeizhou.animation.loader.ResourceStreamLoader
import com.github.penfeizhou.animation.webp.WebPDrawable
import com.wxn.learncompose.MyApp
import com.wxn.learncompose.R

@Composable fun AnimPager3() {
    Box(
        modifier = Modifier.fillMaxSize().background(Color(0xFF000000)),
        contentAlignment = Alignment.Center
    ){

        AWebpView(R.drawable.stars, modifier = Modifier.size(360.dp))
    }
}


@Composable fun AWebpView(resId:Int, modifier : Modifier = Modifier) {
    AndroidView(
        modifier = modifier,
        factory = {context ->
            ImageView(context).apply {
                this.setImageDrawable(WebPDrawable(ResourceStreamLoader(MyApp.context(), R.drawable.stars)))
            }
        }, update = {

        })
}

